package com.sian.atmosphere.services;

import java.util.HashMap;
import java.util.Map;

import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.AtmosphereResourceFactory;
import org.springframework.stereotype.Service;

@Service
public class PresentService {
	Map<String, String> onlineUUID = new HashMap<String, String>();
	
	public void register(String userId, String uuid)
	{
		onlineUUID.put(userId, uuid);
	}
	
	public void remove(String userId)
	{
		onlineUUID.remove(userId);
	}
	
	public AtmosphereResource getAtmosphereResource(String userId)
	{
		String uuid = onlineUUID.get(userId);
		
		if(null != uuid)
		{
			return AtmosphereResourceFactory.getDefault().find(uuid);
		}
		return null;
	}
}
